<div class="layui-card-header layui-card">
    <span class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">首页</a>
        <a><cite>资金归集订单</cite></a>
    </span>
</div>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">资金归集订单</li>
            </ul>



            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-row">
                        <div class="layui-form" style="float:right; margin-bottom: 10px;">
                            <div class="layui-form-item" style="margin:0;">

                                <div class="layui-input-inline">
                                    <input type="text"id="payOrderId" placeholder="支付订单号" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-input-inline">
                                    <input type="text" id="channelOrderNo" placeholder="渠道订单号" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-input-inline">
                                    <input type="text"id="transInUserId" placeholder="分账用户ID" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-input-inline">
                                    <select id="status" lay-search="">
                                        <option value="">分账状态</option>
                                        <option value="1">成功</option>
                                        <option value="0">失败</option>
                                    </select>
                                </div>
                                <button id="search" class="layui-btn" data-type="reload">搜索</button>
                            </div>
                        </div>
                    </div>

                    <table class="layui-hide center" id="cList"></table>
                </div>

            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['table','util', 'form'], function(){
        var table = layui.table
        ,$ = layui.$
        ,form = layui.form
        ,element = layui.element;

        element.render('breadcrumb', 'breadcrumb');//渲染导航信息


        var tplStatus = function(d){
            if(d.status == 0) {
                return "<span style='color: red'>失败</span>";
            }else if(d.status == 1) {
                return "<span style='color: green'>成功</span>";
            }
        };

        table.render({
            elem: '#cList'
            ,url: layui.setter.baseUrl + '/pay_cash_coll_record/list'
            ,where: { access_token: layui.data(layui.setter.tableName).access_token}
            ,id: 'tableReload'
            ,cols: [[
                {field:'payOrderId', title: '支付订单号'}
                ,{field:'channelOrderNo', title: '渠道订单号'}
                ,{field:'transInUserName', title: '分账收入方姓名'}
                ,{field:'transInUserAccount',  title: '分账收入方账号'}
                ,{field:'transInUserId',  title: '分账收入方用户ID'}
                ,{title: '分账百分比', templet: "<span>{{ d.transInPercentage }}% </span>"}
                ,{title: '分账金额（元）', templet: "<span>{{ d.transInAmount/100 }} </span>"}
                ,{title: '状态',templet: tplStatus }
                ,{field:'remark',title: '备注信息'}
                ,{field: 'createTime',  title: '时间', templet: '<div>{{ layui.util.toDateString(d.createTime) }}</div>' }
            ]]
            ,page: true
            ,skin: 'line'
        });



        // 搜索
        var $ = layui.$, active = {
            reload: function(){
                var payOrderId = $('#payOrderId').val();
                var channelOrderNo = $("#channelOrderNo").val();
                var transInUserId = $("#transInUserId").val();
                var status = $("#status").val();
                //执行重载
                table.reload('tableReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        payOrderId: payOrderId,
                        channelOrderNo: channelOrderNo,
                        transInUserId : transInUserId,
                        status : status
                    }
                });
            }
        };
        $('#search').on('click', function() {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


        // 渲染表单
        form.render();
    });
    
</script>
